<?php
/**
 * oscshop2 B2C电子商务系统
 *
 * ==========================================================================
 * @link      http://www.oscshop.cn/
 * @copyright Copyright (c) 2015-2017 oscshop.cn. 
 * @license   http://www.oscshop.cn/license.html License
 * ==========================================================================
 *
 * @author    李梓钿
 *
 * 评论
 * 
 */
namespace osc\common\service;
use think\Db;
class Comment{
	
	/**
	 * 取得商品评论 
	 *
	 * $goods_id 商品id
	 * $type     类型
	 * $score    评分
	 * $status   状态
	 * $page	  页码
	 * $page	  数据量
	 */
	function get_goods_comment($goods_id,$type,$score=0,$status=1,$page=0,$num=10){
				
		$limit = ($num * $page) . ",".$num."";	
		
		if($score!=0){			
			if($score==2){
				//小于等于2
				$where['score']=['elt',$score];
			}
			if($score==3){
				$where['score']=['eq',$score];
			}
			if($score==4){
				//大于等于4
				$where['score']=['egt',$score];
			}	
				
		}
		$where['goods_id']=['eq',$goods_id];	
		$where['status']=['eq',$status];
		$where['type']=['eq',$type];
		
		return Db::name('comment')->where($where)->limit($limit)->order('id desc')->select();
		
	}

}  